<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 39  </title>
    <style>
        div {
            font-size: 30px;
        }
    </style>
    <script src="https://unpkg.com/vue@next"></script>

</head>
<body>
<div id="root"></div>
</body>
<script>

    // computed 计算属性
    const app = Vue.createApp({
        setup(props, context) {
            const { ref, watch} = Vue;
            const name = ref('jack')

            // 具备一定的惰性 lazy （指首次加载不执行，需要数据发生变化后才执行的操作）
            // 参数可以拿到原始值和当前值
            watch(name, (currentValue, prevValue)=>{
                console.log('currentValue=',currentValue, 'prevValue=',prevValue)
            })

            return {
                name,
            }
        },

        // created 实例被完全初始化之前
        template: `
          <div>
            <div>Name: <input type="text" v-model="name"/></div>
            <div>Name is {{name}}</div>
          </div>
        `
    });



    const vm = app.mount('#root');
</script>
</html>